﻿#include "MyThread.h"
#include "mcsy.h"
#include <QDebug>
#include <QTime>
#include "mcsythread.h"

MyThread ::MyThread(QObject *parent): QThread(parent)
{
    m_abort=false;
}
void MyThread::run()
{
    //float starttime=timeGetTime()/1000.0;
    MCsyThread * t=(MCsyThread *)this->parent();
    qDebug()<<t->m_test1;

    miaobiao.start();
    double f0;
    //sig1=new CMySig();
    sig1.setXn(0);
    long count=0;
    long tick=10;//ms
    while (!m_abort)
    {
        QList<double> l;
        //double t=timeGetTime()/1000.0-starttime;
        f0=miaobiao.elapsed()/1000.0;
        l.append(f0);
        l.append(t->card->getchanelVolt(7));
        l.append(t->card->getchanelVolt(8));
        l.append(t->card->getchanelVolt(10));
        l.append(t->card->getchanelVolt(6));
        sig1.setOneData(l,sig1.getXn());
       if (count % 10 ==0){//every 100ms
           emit dataArrive(l);
       }
        if (f0>10)//10s
        {
            break;
        }
        usleep(tick*1000);//10ms
    }
    emit dataAllFinish(&sig1);
    qDebug()<<"emit from mythread";
}
MyThread::~MyThread()
{
}
void MyThread::stopProcess()
{
    m_abort = true;
}
